package com.dexgdx.game.factory;

import com.dexgdx.game.Game;
import com.dexgdx.game.actor.AbstractActor;
import com.dexgdx.game.actor.Enemy;
import com.dexgdx.game.actor.JSONActor;
import com.dexgdx.game.actor.Player;
import com.dexgdx.game.constants.PlayerType;
import com.dexgdx.game.structure.Region;

public class ActorFactory {

	public static AbstractActor loadFromJSONActor(JSONActor jSONActor){
		
		AbstractActor actor = null;
		Region region = null;
		
		if(jSONActor.isSimpleActorRegion()){
			region = new Region(jSONActor.getX(), jSONActor.getY(), Game.defaultConstants.getActorRingHeight(), Game.defaultConstants.getActorRingWidth());
		}
		else {
			region = new Region(jSONActor.getX(), jSONActor.getY(), jSONActor.getHeight(), jSONActor.getWidth());
		}
		
		if(jSONActor.getPlayerType() == PlayerType.ENEMY){
			actor = new Enemy(jSONActor.getImagePath());
		}
		else {
			actor = new Player(jSONActor.getImagePath());
		}
		
		actor.setFromRegion(region);
		
		return actor;
	}
}
